import React, { ReactNode } from 'react'
import Error401 from '@/pages/Error/401'

interface IAccess {
  accessible: boolean
  fallback?: ReactNode
  children: ReactNode
}

const Access: React.FC<IAccess> = ({ accessible, fallback, children }) => {
  if (!accessible) {
    return fallback ? <>{fallback}</> : <Error401 />
  }
  return <>{children}</>
}

export default Access
